<template>
	<view>
		<fa-navbar title="选择所属房产"></fa-navbar>
		<view class="assetsItem" v-for="(item, index) in assetsList" :key="index" @click="select(index)">
			<u-row>
				<u-col span="10.5">
					<text :class="item.ID === selectedId ? 'selected' : '' ">{{item.OrgName}}</text>
				</u-col>
				<u-col span="1.5" v-show="item.ID === selectedId"><image class="selected-image" src="/static/images/selected.svg" /></u-col>
			</u-row>
		</view>
	</view>
</template>

<script>
	import faNavbar from '@/components/fa-navbar/fa-navbar.vue'
	import FaIcon from '@/components/fa-icon/fa-icon.vue'
	export default {
		components: {FaIcon, faNavbar},
		data() {
			return {
				assetsList: [],
				selectedId: "",
			}
		},
		async onLoad(params) {
			if (params.selectedId) {
				this.selectedId = params.selectedId;
			}
			// 获取房产列表
			let res = await this.$api.getOrgList();
			this.assetsList = res.data;
		},
		methods: {
			select(index) {
				this.selectedId = this.assetsList[index].ID;
				uni.$emit('onChooseAssets', this.assetsList[index]);
				uni.navigateBack();
			}
		}
	}
</script>

<style scoped>
.assetsItem {
	font-style: normal;
	color: #555555;
	height: 100rpx;
	line-height: 100rpx;
	padding: 0 30rpx;
}
.selected {
	color: rgba(55, 120, 233, 0.980392156862745) !important;
}
.selected-image {
	width: 40rpx;
	height: 40rpx;
	display: block;
}
.u-row {
	border-bottom: 1px solid #ECECF0;
	font-size: 28rpx;
	font-family: PingFangSC-Regular, PingFang SC;
	font-weight: 400;
	color: #2A2A2A;
}
</style>
